<?php
App::uses('AppModel', 'Model');
/**
 * User Model
 *
 * @property AccessLevel $AccessLevel
 * @property User $User
 * @property BranchSubject $BranchSubject
 * @property Branch $Branch
 * @property Category $Category
 * @property Exam $Exam
 * @property Log $Log
 * @property Message $Message
 * @property Option $Option
 * @property Periodexam $Periodexam
 * @property Resultexam $Resultexam
 * @property Stage $Stage
 * @property Studentbranch $Studentbranch
 * @property StudentSubject $StudentSubject
 * @property Student $Student
 * @property Subject $Subject
 * @property TeacherSubject $TeacherSubject
 * @property Teatcher $Teatcher
 * @property Term $Term
 * @property Uniyear $Uniyear
 * @property User $User
 */
class User extends AppModel {

/**
 * Validation rules
 *
 * @var array
 */
  public function beforeSave() {
    if (isset($this->data[$this->alias]['password'])) {
        $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
    }
    return true;
   }
	
	public $validate = array(
		'username' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'password' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'access_level_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
	);

	//The Associations below have been created with all possible keys, those that are not needed can be removed

/**
 * belongsTo associations
 *
 * @var array
 */
	public $belongsTo = array(
		'AccessLevel' => array(
			'className' => 'AccessLevel',
			'foreignKey' => 'access_level_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
	);

/**
 * hasMany associations
 *
 * @var array
 */
	

}
